using AutoMapper;
using ChikovMF.Application.Common.Interfaces;
using ChikovMF.Application.Common.Mappings;
using ChikovMF.Context;

namespace ChikovMF.Tests
{
    public abstract class TestQueryBase : IDisposable
    {
        protected readonly ChikovMFContext _context;
        protected readonly IMapper _mapper;

        public TestQueryBase()
        {
            _context = ChikovMFContextFactory.Create();

            var configurationProvider = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AssemblyMappingProfile(typeof(IChikovMFContext).Assembly));
            });
            _mapper = configurationProvider.CreateMapper();
        }

        public void Dispose()
        {
            ChikovMFContextFactory.Destroy(_context);
        }
    }
}